<template>
  <div class="home-container">
    <!-- 导航栏 -->
    <el-header class="header">
      <div class="logo">Vue App</div>
      <el-switch
        :model-value="isDark"
        @update:model-value="emit('update:isDark', $event)"
        active-text="暗黑"
        inactive-text="明亮"
        style="margin-left: 20px"
      />
      <el-menu 
        mode="horizontal"
        background-color="transparent"
        text-color="#3B82F6"
        active-text-color="#1E3A8A"
        class="nav-menu">
        <el-menu-item index="1">首页</el-menu-item>
        <el-menu-item index="2">产品</el-menu-item>
        <el-menu-item index="3">关于</el-menu-item>
        <el-menu-item index="4">联系</el-menu-item>
        <el-menu-item index="5" @click="$router.push('/admin')">管理后台</el-menu-item>
      </el-menu>
    </el-header>

    <!-- 主视觉区 -->
    <el-main class="main-visual">
      <div class="content">
        <h1>欢迎来到我们的平台</h1>
        <p class="subtitle">构建现代化、响应式的Web应用</p>
        <el-button type="primary" size="large">立即开始</el-button>
      </div>
      <div class="graphic">
        <div class="circle"></div>
        <div class="square"></div>
        <div class="triangle"></div>
      </div>
    </el-main>

    <!-- 特色功能 -->
    <el-row class="features" :gutter="20">
      <el-col :span="8" v-for="(feature, index) in features" :key="index">
        <el-card shadow="hover" class="feature-card">
          <div class="feature-icon">
            <component :is="feature.icon" />
          </div>
          <h3>{{ feature.title }}</h3>
          <p>{{ feature.description }}</p>
        </el-card>
      </el-col>
    </el-row>

    <!-- 页脚 -->
    <el-footer class="footer">
      <p>© 2025 Vue App. 保留所有权利</p>
    </el-footer>
  </div>
</template>

<script setup>
import { StarFilled, TrendCharts, Setting } from '@element-plus/icons-vue'
import { defineProps } from 'vue'
import { useRouter } from 'vue-router'

const $router = useRouter()

const props = defineProps({
  isDark: Boolean
})

const emit = defineEmits(['update:isDark'])

const features = [
  {
    icon: StarFilled,
    title: '优质服务',
    description: '提供专业可靠的解决方案'
  },
  {
    icon: TrendCharts,
    title: '数据分析',
    description: '实时监控和可视化数据'
  },
  {
    icon: Setting,
    title: '定制开发',
    description: '根据需求定制专属功能'
  }
]
</script>

<style scoped>
.home-container {
  min-height: 100vh;
  width: 100vw;
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  background-color: var(--bg-color);
  color: var(--text-color);
  transition: all 0.3s ease;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--bg-color);
  padding: 0 20px;
  border-bottom: 1px solid var(--border-color);
  transition: all 0.3s ease;
}

.logo {
  color: var(--primary-color);
  font-size: 24px;
  font-weight: bold;
  transition: all 0.3s ease;
}

.main-visual {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 80px 10%;
  min-height: 60vh;
}

.content {
  max-width: 50%;
  animation: fadeIn 1s ease;
}

h1 {
  font-size: 48px;
  margin-bottom: 20px;
  color: var(--primary-color);
  transition: all 0.3s ease;
}

.subtitle {
  font-size: 18px;
  color: var(--text-color);
  opacity: 0.8;
  margin-bottom: 30px;
  transition: all 0.3s ease;
}

.graphic {
  position: relative;
  width: 400px;
  height: 400px;
}

.circle, .square, .triangle {
  position: absolute;
  background-color: var(--primary-color);
  opacity: 0.1;
  transition: all 0.5s ease;
}

.circle {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  top: 50px;
  left: 100px;
  animation: pulse 4s infinite alternate;
}

.square {
  width: 150px;
  height: 150px;
  top: 150px;
  left: 50px;
  animation: rotate 8s infinite linear;
}

.triangle {
  width: 0;
  height: 0;
  border-left: 100px solid transparent;
  border-right: 100px solid transparent;
  border-bottom: 173px solid var(--primary-color);
  top: 50px;
  left: 200px;
  animation: float 6s infinite ease-in-out;
}

.features {
  padding: 60px 10%;
}

.feature-card {
  height: 100%;
  transition: all 0.3s ease;
  cursor: pointer;
}

.feature-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.feature-icon {
  font-size: 40px;
  color: var(--primary-color);
  margin-bottom: 20px;
  transition: all 0.3s ease;
}

.footer {
  background-color: var(--primary-color);
  color: white;
  text-align: center;
  padding: 20px;
  margin-top: auto;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 0.1; }
  100% { transform: scale(1.1); opacity: 0.2; }
}

@keyframes rotate {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-20px); }
}

.nav-menu :deep(.el-menu) {
  background-color: transparent;
  border-bottom: none;
}

.nav-menu :deep(.el-menu-item) {
  font-size: 14px;
  padding: 0 20px;
  height: 60px;
  line-height: 60px;
  margin: 0 5px;
  border-radius: 4px;
  transition: all 0.3s;
}

.nav-menu :deep(.el-menu-item:hover) {
  background-color: rgba(59, 130, 246, 0.1);
}

.nav-menu :deep(.el-menu-item.is-active) {
  background-color: rgba(59, 130, 246, 0.2);
  color: var(--primary-color);
}
</style>
